#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <unordered_set>
using namespace std;
const int N=1e5+10;
vector<int> son[N];
int flg;
int maxn;
int pos;
void prePrint(int rt)
{
	if(pos++)
		cout<<' '<<rt;
	else
		cout<<rt;
	for(int i=0;i<son[rt].size();i++)
		prePrint(son[rt][i]);
		
}
int main()
{
	int n;
	int rt;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int cur;
		scanf("%d",&cur);
		if(cur==0)
			rt=i;
		else
			son[cur].push_back(i);
	}
	flg=2;
	queue<int> q;
	q.push(rt);
	unordered_set<int> has;
	while(q.size())
	{
		int sz=q.size();
		
		while(sz--)
		{
			int u=q.front();
			q.pop();
			maxn=max((int)son[u].size(),maxn);
			has.insert(son[u].size());
			for(int i=0;i<son[u].size();i++)
			{
				q.push(son[u][i]);
			}
		}
	}
//	cout<<rt<<endl;
	cout<<maxn<<' ';
	if(has.size()==2 || has.size()==1)
	{
		cout<<"yes";
	}
	else{
		cout<<"no";
	}
	cout<<endl;
	prePrint(rt);
	return 0;
}
